package com.liqi.web.controller.items;

import com.liqi.common.annotation.Log;
import com.liqi.common.core.controller.BaseController;
import com.liqi.common.core.domain.AjaxResult;
import com.liqi.common.core.page.TableDataInfo;
import com.liqi.common.enums.BusinessType;
import com.liqi.common.utils.poi.ExcelUtil;
import com.liqi.items.domain.TServiceDeviceInventory;
import com.liqi.items.service.ITServiceDeviceInventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 一体机事项清单Controller
 * 
 * @author shiteng
 * @date 2023-05-12
 */
@RestController
@RequestMapping("/items/serviceDeviceInventory")
public class TServiceDeviceInventoryController extends BaseController
{
    @Autowired
    private ITServiceDeviceInventoryService tServiceDeviceInventoryService;

    /**
     * 查询一体机事项清单列表
     */
    @PreAuthorize("@ss.hasPermi('items:serviceDeviceInventory:list')")
    @GetMapping("/list")
    public TableDataInfo list(TServiceDeviceInventory tServiceDeviceInventory) {
        startPage();
        List<TServiceDeviceInventory> list = tServiceDeviceInventoryService.selectTServiceDeviceInventoryList(tServiceDeviceInventory);
        return getDataTable(list);
    }

    /**
     * 导出一体机事项清单列表
     */
    @PreAuthorize("@ss.hasPermi('items:serviceDeviceInventory:export')")
    @Log(title = "一体机事项清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TServiceDeviceInventory tServiceDeviceInventory) {
        List<TServiceDeviceInventory> list = tServiceDeviceInventoryService.selectTServiceDeviceInventoryList(tServiceDeviceInventory);
        ExcelUtil<TServiceDeviceInventory> util = new ExcelUtil<>(TServiceDeviceInventory.class);
        util.exportExcel(response, list, "一体机事项清单数据");
    }

    /**
     * 获取一体机事项清单详细信息
     */
    @PreAuthorize("@ss.hasPermi('items:serviceDeviceInventory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(tServiceDeviceInventoryService.selectTServiceDeviceInventoryById(id));
    }

    /**
     * 新增一体机事项清单
     */
    @PreAuthorize("@ss.hasPermi('items:serviceDeviceInventory:add')")
    @Log(title = "一体机事项清单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody TServiceDeviceInventory tServiceDeviceInventory) {
        tServiceDeviceInventory.setCreateBy(getUsername());
        tServiceDeviceInventory.setStatus(0);
        return toAjax(tServiceDeviceInventoryService.insertTServiceDeviceInventory(tServiceDeviceInventory));
    }

    /**
     * 修改一体机事项清单
     */
    @PreAuthorize("@ss.hasPermi('items:serviceDeviceInventory:edit')")
    @Log(title = "一体机事项清单", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody TServiceDeviceInventory tServiceDeviceInventory) {
        tServiceDeviceInventory.setUpdateBy(getUsername());
        return toAjax(tServiceDeviceInventoryService.updateTServiceDeviceInventory(tServiceDeviceInventory));
    }

    /**
     * 删除一体机事项清单
     */
    @PreAuthorize("@ss.hasPermi('items:serviceDeviceInventory:remove')")
    @Log(title = "一体机事项清单", businessType = BusinessType.DELETE)
	@DeleteMapping("/delete")
    public AjaxResult remove(@RequestBody List<String> ids) {
        return toAjax(tServiceDeviceInventoryService.deleteTServiceDeviceInventoryByIds(ids));
    }
}
